from django.conf.urls import url
from rest_framework_jwt.views import obtain_jwt_token
from .views import home
from .views import user, image, sku, order, permission, group, spu, admin
from rest_framework.routers import DefaultRouter


urlpatterns = [
    # url(r'^authorizations/$', LoginAdmin.as_view())
    url(r'^authorizations/$', obtain_jwt_token),
    url(r'statistical/total_count/$', home.UserTotalCountAPIView.as_view()),
    url(r'statistical/day_increment/$', home.UserDailyCountView.as_view()),
    url(r'statistical/day_active/$', home.UserDailyActiveCountView.as_view()),
    url(r'statistical/day_orders/$', home.UserDailyOrderCountView.as_view()),
    url(r'statistical/month_increment/$', home.UserMonthCountView.as_view()),
    url(r'statistical/goods_day_views/$', home.UserCategoryCountAPIView.as_view()),
    url(r'users/$', user.UserListAPIView.as_view()),
    url(r'skus/simple/$', image.SimpleSKUView.as_view()),
    url(r'skus/categories/$', sku.ThreeJiCategoryView.as_view()),
    url(r'goods/simple/$', sku.SPUSimpleView.as_view()),
    url(r'goods/(?P<pk>\d+)/specs/$', sku.SPUSpecView.as_view()),
    url(r'orders/$', order.OrderInfoListView.as_view()),
    url(r'orders/(?P<pk>\d+)/$', order.OrderInfoDetailView.as_view()),
    url(r'orders/(?P<pk>\d+)/status/$', order.OrderInfoDetailView.as_view()),
    url(r'permission/content_types/$', permission.ContentTypeView.as_view()),
    url(r'permission/simple/$', group.NewPermissionList.as_view()),
    url(r'goods/brands/simple/$', spu.BrandInfoView.as_view()),
    url(r'goods/channel/categories/$', spu.CategoryInfoView.as_view()),
    url(r'goods/channel/categories/(?P<pk>\d+)/$', spu.CategoryInfoView.as_view()),
    url(r'permission/groups/simple/$', admin.GroupListInfoView.as_view()),



]

# 创建路由对象
router = DefaultRouter()
# 注册路由
router.register(r'skus/images', image.ImageSkuViewSet, basename='image')
# 添加到路由集中
urlpatterns += router.urls

router.register(r'skus', sku.SUKModelViewSet, basename='sku')
urlpatterns += router.urls

# 权限管理
router.register(r'permission/perms', permission.PermissionListView, basename='permission')
urlpatterns += router.urls

# 分组管理
router.register(r'permission/groups', group.GroupListView, basename='group')
urlpatterns.extend(router.urls)

# spu管理
router.register(r'goods', spu.SpuListView, basename='spu')
urlpatterns += router.urls

# 管理员管理
router.register(r'permission/admins', admin.AdminListModelView, basename='admin')
urlpatterns += router.urls